package singleton;

// 内存保障 jdk1.5之前不能使用，禁止指令重排优化在1.5才能正确工作。
public class Singleton4 {

    private Singleton4() {}

    private static volatile Singleton4 single = null;

    public static Singleton4 getInstance() {
        if (single == null) {
            synchronized (Singleton4.class) {
                if(single == null){
                    single = new Singleton4();
                }
            }
        }
        return single;
    }
}
